/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gui;

import javax.microedition.lcdui.*;
import app.ConsultaCartelera;
import conexion.Conexion;
/**
 * @author REX
 */
public class Compra extends Canvas implements CommandListener {
    /**
     * constructor
     */
    int width;
    int height;
    private final String url = "http://www.ngwise.mobi/cm/boletos.php";
    private FormularioCompra fc;
    public Compra(FormularioCompra fc) {
        try {
            width  = getWidth();
            height = getHeight();
            this.fc = fc;
	    setCommandListener(this);
	    addCommand(new Command("Finalizar", Command.OK, 1));
        } catch(Exception e) {
            e.printStackTrace();
        }
    } 
    public void limpiaPantalla(Graphics g){
        g.setColor( 255, 255, 255 );
        g.fillRect( 0, 0, width, height );
    }
    /**
     * paint
     */
    public void paint(Graphics g) {
        limpiaPantalla(g);
        g.setColor(0, 0, 0);
        String cantidad = fc.getBoletos().getString();
        Image img = Conexion.cargaImagen(url,"qty",cantidad);
        g.drawImage(img, width/2, height/2, Graphics.VCENTER | Graphics.HCENTER);
    }
    public void commandAction(Command command, Displayable displayable) {
         if(command.getLabel().equals("Finalizar")){
            MenuPrincipal mp = fc.getMc().getMc().getMp();
            mp.getMidlet().pantalla.setCurrent(mp);
        }
    }

}